<?php

namespace app\models;

use app\core\components\Tree;
use app\core\helpers\ArrayHelper;
use Yii;

/**
 * This is the model class for table "{{%ad_position}}".
 *
 * @property integer $id
 * @property string $name
 * @property integer $num
 * @property integer $width
 * @property integer $height
 */
class AdPosition extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%ad_position}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name'], 'required'],
            [['num', 'width', 'height'], 'integer'],
            [['name'], 'string', 'max' => 20],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '广告位',
            'num' => '显示条数',
            'width' => '宽度',
            'height' => '高度',
        ];
    }

    public static function treeArr() {
        $menus = static::find()->asArray()->all();
       return ArrayHelper::map($menus, 'id', 'name');
    }
}
